<?php

class Zhishidi_Express_Block_Adminhtml_Zone_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form {

    protected function _prepareForm() {
        $form = new Varien_Data_Form();
        $this->setForm($form);
        $fieldset = $form->addFieldset('expressZoneFieldset', array('legend' => Mage::helper('zhishidi_express')->__("Express Zone information")));


        $typeCollection = Mage::getModel('zhishidi_express/type')->getCollection();
        $typeArray = array();
        foreach ($typeCollection as $type) {
            $typeArray[] = array(
                'value' => $type->getId(),
                'label' => $type->getTypeName(),
            );
        }
        $fieldset->addField('zone_type', 'select', array(
            'name' => 'zone_type',
            'label' => Mage::helper('zhishidi_express')->__('Zone Type'),
            'title' => Mage::helper('zhishidi_express')->__('Zone Type'),
            'required' => true,
            'values' => $typeArray,
        ));

        $fieldset->addField('zone_name', 'text', array(
            'name' => 'zone_name',
            'label' => Mage::helper('zhishidi_express')->__('Zone Name'),
            'title' => Mage::helper('zhishidi_express')->__('Zone Name'),
            'class' => 'required-entry',
            'required' => true,
        ));

        $fieldset->addField('zone_price', 'text', array(
            'name' => 'zone_price',
            'label' => Mage::helper('zhishidi_express')->__('Zone Price'),
            'title' => Mage::helper('zhishidi_express')->__('Zone Price'),
            'style' => 'width:100px;',
            'required' => false,
        ));


        $fieldset->addField('zone_unit', 'text', array(
            'name' => 'zone_unit',
            'label' => Mage::helper('zhishidi_express')->__('Zone Unit'),
            'title' => Mage::helper('zhishidi_express')->__('Zone Unit'),
            'style' => 'width:100px;',
            'required' => false,
        ));

        $groupCollection = Mage::getModel('zhishidi_express/group')->getCollection();
        $groupArray = array();

        array_unshift($groupArray, array());
        foreach ($groupCollection as $group) {
            $groupArray[] = array(
                'value' => $group->getId(),
                'label' => $group->getGroupName(),
            );
        }
        $fieldset->addField('zone_group', 'select', array(
            'name' => 'zone_group',
            'label' => Mage::helper('zhishidi_express')->__('Zone Group'),
            'title' => Mage::helper('zhishidi_express')->__('Zone Group'),
            'values' => $groupArray,
        ));

        $fieldset->addField('zone_status', 'select', array(
            'name' => 'zone_status',
            'label' => Mage::helper('zhishidi_express')->__('Status'),
            'title' => Mage::helper('zhishidi_express')->__('Status'),
            'required' => true,
            'values' => array(
                array(
                    'value' => 'public',
                    'label' => Mage::helper('zhishidi_express')->__('Public'),
                ),
                array(
                    'value' => 'hidden',
                    'label' => Mage::helper('zhishidi_express')->__('Hidden'),
                )
            ),
        ));

        if (Mage::getSingleton('adminhtml/session')->getExpressZoneData()) {
            $form->setValues(Mage::getSingleton('adminhtml/session')->getExpressZoneData());
            Mage::getSingleton('adminhtml/session')->setExpressZoneData(null);
        } elseif (Mage::registry('express_zone_data')) {
            $form->setValues(Mage::registry('express_zone_data')->getData());
        }
        return parent::_prepareForm();
    }

}